<?php
//mail("induneth87@gmail.com","test","test");
session_start();
error_reporting(false);
$validation_error = array();
function __autoload($class_name) {
    require_once 'class/'.$class_name . '.php';
}
$member_obj = new Member();
if(isset($_POST['confirm_details'])) {
    $en_key = '&56TCVH%#*P*W&vddbsd&^%';
    $enc = new Encryption;
    $validation_obj = new Validation();
    $validation_error = array();
    $user_values = $_POST;
    foreach ($user_values as $key => $value) {
    	 $key = trim($value);
        if($validation_obj->check_blank(trim($value) == true)) {
        	$validation_error[$key] = "<span class='error'>$key is blank</span>";
        }
    }
    unset($validation_error['full_name'],$validation_error['postal_address']);
    if($validation_obj->validate_email($user_values['user_email']) == false) {
    	$validation_error['user_email'] = "<span class='error'>Please enter Valid Email</span>";
    }

    if(trim($user_values['user_password']) == '') {
        $validation_error['user_password'] = "<span class='error'>Please enter Password</span>";
    }
    if($user_values['user_password'] != $user_values['confirm_password']) {
        $validation_error['confirm_password'] = "<span class='error'>Both password should be same</span>";
    }
    if($member_obj->member_exist(trim($user_values['user_email'])) != false) {
        $validation_error['user_email'] = "<span class='error'>This email already exist in the system</span>";
    }
    if(trim($user_values['contact_number']) == '') {
        $validation_error['contact_number'] = "<span class='error'>Please enter Contact Number</span>";
    }
    $img = new Securimage();
    $valid = $img->check($_POST['image_code']);

    if($valid == FALSE) {
      $validation_error['image_code'] = "<span class='error'>Sorry, the code you entered was invalid</span>";
    }
    if(empty($validation_error)) {
        $_SESSION['user_verification'] = 'success';
        $_SESSION['tamil_mat_user'] = $user_values['user_email'];
        $verify_details = array('member_email'=>$user_values['user_email'],
            'creation_date' => date('Y-m-d H:i:s'),
            'last_update' => date('Y-m-d H:i:s'),
            'status' => 'P',
            'first_name'=> $user_values['first_name'],
             'last_name'=> $user_values['last_name'],
            'contact_number' => $user_values['contact_number'],
            'member_password' => $enc->encrypt($en_key, $user_values['user_password']),
            'member_status' => 'G'

        );


        $member_obj->create_member($verify_details);
        // Encrypt the Source Text
        $encstr = $enc->encrypt($en_key, $user_values['user_email']);
        $to_name = $user_values['user_email'];
        $from_name = 'Hotel With Offers';
        $click_link = 'http://www.hotelswithoffers.com/registration_step_two.php?tmu&#61;'.urlencode($encstr);

       // $from_email = 'exceldatabank@yahoo.com';
       // $email_obj = new EmailFunc($to_name, $to_name, $from_name, $from_email);
        $email_message = "<img src='http://www.hotelswithoffers.com/images/logo.png' /><br/>";
        $email_message .= "Dear " . $to_name . ",<br/><br/>";
        $email_message .= "Thank you for verify with us. please click below link to complete your verification.<br/> ".$click_link . " <br/><br/>";
        $email_message .= "Regards <br/>";
     echo   $email_message .= "hotelswithoffers   Team.\n";
        //$email_obj->buildMessage('Your Email Verification', $email_message);
       // $email_obj->sendmail();
//echo $email_message;exit;
        // To send HTML mail, the Content-type header must be set
        $subject = 'Email Verification from hotelswithoffers.com';
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        // Additional headers
        $headers .= 'From: Your Email Verification <induneth87@gmail.com>' . "\r\n";
        // Mail it
        mail("induneth87@gmail.com", $subject, $email_message, $headers);
 exit;
        header("Location:verification_success.php");

	}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hotels With Offers</title>
<script language="Javascript" type="text/javascript" src="js/jquery-1.4.1.js"></script>
<script language="Javascript" type="text/javascript" src="js/jquery.lwtCountdown-1.0.js"></script>
<script language="Javascript" type="text/javascript" src="js/misc.js"></script>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script language="javascript">
         $(document).ready(function() {
            $("#submit_details").validate({
                rules: {
                    user_password: "required",
                    confirm_password: {
                    equalTo: "#user_password"
                    }

                }
            });
        });
        function check_member(member_email) {
             $.ajax({
        url: "extra_functions.php",
	type: "POST",
	cache: false,
        async:false,
	data: {member_email:member_email,member_check:true },
	success: function(theResponse)
	{
            if(theResponse == 'available'){
                $('#email_error').html('<span class="error">This email already exist in the system</span>');
            } else {
                $('#email_error').html('');
            }
        }
     });
        }
	</script>

</head>

<body>
<div id="wrapper">
    <div id="header">
        <div class="headerRight">
            <form action="member_login.php" method="post" name="member_login">
            <div class="username"><input class="usernametxtbox" type="text" value="username" onfocus="if (this.value == 'username') { this.value = ''; }" onblur="if (this.value == '') { this.value = 'username'; }" /></div>
            <div class="password"><input class="passwordtxtbox" type="text" value="password" onfocus="if (this.value == 'password') { this.value = ''; }" onblur="if (this.value == '') { this.value = 'password'; }" /></div>
            <div class="login"><input class="logmein" name="" type="submit" value="" /></div>
            <span class="account"><a href="#">No Account? Register Now!</a></span>
            <div class="sociallinks"><a href="#"><img src="images/twt.png" alt="Tweet about Hotel with Offers" /></a><a href="#"><img src="images/fb.png" alt="Share Hotel with Offers on Facebook" /></a><a href="#"><img src="images/ln.png" alt="Connect Hotel with Offers with LinkedIn" /></a></div>
            </form>
            <div class="clear"></div>
        </div>
        <div class="logo"><img src="images/logo.png" width="255" height="81" alt="Hotels with Offers" /></div>
        <div class="clear"></div>
    </div>

<div class="contentPane">
  <div id="sidebar">
    <span class="menu"><img src="images/call.png" alt="Advertise with Hotel with Offers" class="callus"  /></span>
    <div class="joinus">
      <h1>INVITE A FRIEND</h1>
      <h2>Tell a friend and win Rs100.00</h2>
      <div class="joinbtn"><a href="#">LEARN&nbsp;MORE</a></div>
     </div>
    <div class="reserve"><span class="reserveitem">Reserved for :</span> <span class="reserveitem">advertising</span> <span class="reserveitem">latest news</span> <span class="reserveitem">soon ending deals &amp; offers</span></div>
  </div>
  <div class="leftPane">

   <form id="submit_details" name="submit_details" method="post" action="new_member.php">
              <table border="0" cellpadding="0" cellspacing="0" class="Subtable">
                <tbody>
                     <tr>
                    <td>First Name</td>
                    <td><input name="first_name" id="first_name" type="text" value="<?=$user_values['first_name']?>" class="required"></td>
                  </tr>
                    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                  <tr>
                    <td>Last Name</td>
                    <td><input name="last_name" id="last_name" type="text" value="<?=$user_values['last_name']?>" class="required"></td>
                  </tr>
                     <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                  <tr>
                    <td>Email</td>
                    <td><input name="user_email" id="user_email" class="required email" value="<?=$user_values['user_email']?>" onblur="check_member(this.value);" type="text">
                        &nbsp; <?php echo $validation_error['user_email']; ?> <span id="email_error"></span> </td>
                  </tr>
 <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                  <tr>
                    <td>Password</td>
                    <td><input name="user_password" id="user_password" class="required" type="password">
                      &nbsp;
                      <?php echo $validation_error['user_password']; ?></td>
                  </tr>
  <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                  <tr>
                    <td>Confirm Password</td>
                    <td><input name="confirm_password" id="confirm_password" class="required" type="password">
                      &nbsp;
                      <?php echo $validation_error['confirm_password']; ?></td>
                  </tr>
   <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                  <tr>
                    <td>Contact Number</td>
                    <td><input name="contact_number" id="contact_number" type="text" value="<?=$user_values['contact_number']?>" class="required"></td>
                  </tr>
    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                  <tr>
                      <td>&nbsp;</td>
                      <td><input id="subscribe" name="subscribe" type="checkbox" checked="checked" value="1" title="Sign Up for HotelsWithOffers Newsletter" />&nbsp;Send me hotelswithoffers.com Offers</td>
                  </tr>
     <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                 <tr>
                      <td>&nbsp;</td>
                      <td><input id="tc" name="tc" type="checkbox"  value="1" title="Accept Terms and Conditions" />&nbsp;I aggreed to the <a href="#"> Terms and Conditions</a></td>
                  </tr>
      <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                  <tr>
                      <td colspan="2">

                          <div style="width: 290px; float: right; height: 90px">
      <img id="siimage" align="left" style="padding-right: 5px; border: 0" src="securimage_show.php?sid=<?php echo md5(time()) ?>" />

        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="19" height="19" id="SecurImage_as3" align="middle">
			    <param name="allowScriptAccess" value="sameDomain" />
			    <param name="allowFullScreen" value="false" />
			    <param name="movie" value="securimage_play.swf?audio=securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" />
			    <param name="quality" value="high" />

			    <param name="bgcolor" value="#ffffff" />
			    <embed src="securimage_play.swf?audio=securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" quality="high" bgcolor="#ffffff" width="19" height="19" name="SecurImage_as3" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
			  </object>

        <br />

        <!-- pass a session id to the query string of the script to prevent ie caching -->
        <a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = 'securimage_show.php?sid=' + Math.random(); return false"><img src="images/refresh.gif" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a>
</div>
                      </td>
                  </tr>
                  <tr>
                      <td>
                          Type the code above
                      </td>
                      <td>
                          <input type="text" name="image_code" id="image_code" class="required" /><br/>
                           <?php echo $validation_error['image_code']; ?>
                      </td>
                  </tr>
 <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                  <tr>
                    <td colspan="2"><input id="confirm_details" name="confirm_details" value="Confirm" type="submit" class="general_submit"></td>
                  </tr>
                </tbody>
              </table>
            </form>
    <div class="clear"></div>
</div>
</div>
<div class="clear"></div>
</div>
<div id="footerWrapper">
<div id="footer">
  <div class="leftllinks">
    <ul>
      <li><a href="#">getting started</a></li>
      <li><a href="#">hotel offers</a></li>
      <li><a href="#">great deals</a></li>
      <li><a href="#">tour packages</a></li>
      <li><a href="#">blog</a></li>
      <li><a href="#">support</a></li>
    </ul>
  </div>
  <div class="rightllinks">
    <ul>
      <li><a href="#">login</a></li>
      <li><a href="#">register</a></li>
      <li><a href="#">advertise with us</a></li>
      <li><a href="#">post your deals</a></li>
      <li><a href="#">post your hotel offers</a></li>
      <li><a href="#">contact us</a></li>
    </ul>
  </div>
  <div class="footerSocial"><a href="#"><img src="images/twt.png" alt="Tweet about Hotel with Offers" /></a><a href="#"><img src="images/fb.png" alt="Share Hotel with Offers on Facebook" /></a><a href="#"><img src="images/ln.png" alt="Connect Hotel with Offers with LinkedIn" /></a></div>
  <br class="clear" />
  <div class="copyright">© 2011 All Rights Reserved</div>
</div>
</div>
    <script language="javascript" type="text/javascript">
			jQuery(document).ready(function() {
                            <?php $k = 1;
                                foreach ($active_offers as $active_offer) {
                                    $offer_hour = substr($active_offer['offer_end_date'], 11, 2) ;
               $offer_min =  substr($active_offer['offer_end_date'], 14, 2);
               $offer_sec =  substr($active_offer['offer_end_date'], 17, 2);
               $offer_day =  substr($active_offer['offer_end_date'], 8, 2);
               $offer_month =  substr($active_offer['offer_end_date'], 5, 2);
               $offer_year =  substr($active_offer['offer_end_date'], 0, 4);

                            ?>
				$('#countdown_dashboard<?=$k?>').countDown({
					targetDate: {
						'day': 		<?=$offer_day?>,
						'month': 	<?=$offer_month?>,
						'year': 	<?=$offer_year?>,
						'hour': 	<?=$offer_hour?>,
						'min': 		<?=$offer_min?>,
						'sec': 		<?=$offer_sec?>
					}
				});


				<?php $k++; } ?>

			});
		</script>
</body>
</html>
